package token

import (
	"reward-server/forms/request"
	"reward-server/handler"
	"reward-server/service"
	"reward-server/utils"

	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

// TotalSupply() (int64, error)
// BalanceOf(addr string) (int64, error)
// TransferFrom(_to, _value string) (string, error)
// Approve(spender string, _value int64) (string, error)

// TotalSupply 代币总数量
func TotalSupply(c *gin.Context) {

	amount, err := service.NewTokenService().TotalSupply()
	if err != nil {
		utils.GinReply(c, "操作失败", 500, gin.H{})
		return
	}
	utils.GinReply(c, "操作成功", 200, gin.H{
		"amount": amount,
	})
}

// BalanceOf 用户代币数量
func BalanceOf(c *gin.Context) {

	var req request.WishReq
	if err := c.ShouldBindQuery(&req); err != nil {
		zap.S().Errorf("验证数据出错:%v", err)
		handler.HandleValidator(err, c)
		return
	}

	amount, err := service.NewTokenService().BalanceOf(req.Addr)
	if err != nil {
		utils.GinReply(c, "操作失败", 500, gin.H{})
		return
	}
	utils.GinReply(c, "操作成功", 200, gin.H{
		"amount": amount,
	})
}

//接入deepseek 扣除代币
func  DeepSeekToken(c *gin.Context) { 
}
